package leetcode_5000;

import java.util.ArrayList;
import java.util.List;
import java.util.regex.Pattern;
/**
 *@author 周杨
 *CamelcaseMatching_5018 给一个模板 往里面可以随意插任意个小写字母
 *describe:正则
 *2019年4月7日 下午13:49 AC 100%
 */
public class CamelcaseMatching_5018 {
	public static void main(String[] args) {
		CamelcaseMatching_5018 test = new CamelcaseMatching_5018();
		test.camelMatch(new String[] {"FooBar","FooBarTest","FootBall","FrameBuffer","ForceFeedBack"}, "FoBa");
	}
	public List<Boolean> camelMatch(String[] queries, String pattern) {
		List<Boolean> res = new ArrayList<Boolean>();
		StringBuilder sb = new StringBuilder();
		String help = "[^A-Z]*";
		char[] chars = pattern.toCharArray();
		sb.append(help); 
		for(char c:chars) {
			sb.append(c).append(help);
		}
		pattern = sb.toString();
        for(String s:queries) {
        	boolean isMatch = Pattern.matches(pattern, s);
        	res.add(isMatch);
        	//System.out.println(isMatch);
        }
        return res;
    }
}
